home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / XPK / Source / xpkmaster / xbuf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-31  |  1.4 KB  |  60 lines

  1. #ifndef XPKMASTER_XBUF_C
  2. #define XPKMASTER_XBUF_C
  3.  
  4. /* Routinesheader
  5.  
  6.     Name:        xbuf.c
  7.     Main:        xpkmaster
  8.     Versionstring:    $VER: xbuf.c 1.1 (31.03.97)
  9.     Author:        SDI
  10.     Distribution:    PD
  11.     Description:    Xpk buffer handling
  12.  
  13.  1.0   09.10.96 : first real version
  14.  1.1   31.02.97 : now free's password buffer
  15. */
  16.  
  17. #include <pragma/exec_lib.h>
  18. #include <exec/memory.h>
  19. #include <exec/libraries.h>
  20. #include <dos/dos.h>
  21. #include "xpkmaster.h"
  22.  
  23. /************************* alloc and init xbuf ***************************/
  24.  
  25. struct XpkBuffer *initxbuf(void)
  26. {
  27.   struct XpkBuffer *xbuf;
  28.  
  29.   if(!(xbuf = (struct XpkBuffer *) AllocMem(sizeof(struct XpkBuffer),
  30.   MEMF_CLEAR)))
  31.     return 0;
  32.   /* Save the original task priority in case we change it during an
  33.      operation */
  34.  
  35.   xbuf->xb_Priority = FindTask(0L)->tc_Node.ln_Pri;
  36.  
  37.   xbuf->xb_InLen = -1;
  38.  
  39.   return xbuf;
  40. }
  41.  
  42. /***************************** free bufs *******************************/
  43. LONG freebufs(struct XpkBuffer *xbuf)
  44. {                /* Free an XpkBuffer */
  45.   LONG error = xbuf->xb_Result;
  46.  
  47.   closesub(xbuf);        /* Free any open sub-library */
  48.  
  49.   if(xbuf->xb_Flags & XMF_OWNTASKPRI)
  50.     SetTaskPri(FindTask (NULL), xbuf->xb_Priority);
  51.   if(xbuf->xb_Flags & XMF_OWNPASSWORD)
  52.     FreeMem(xbuf->xb_Password, xbuf->xb_PasswordSize);
  53.  
  54.   FreeMem(xbuf, sizeof(struct XpkBuffer));
  55.                 /* Finally, free the handle itself */
  56.   return error;
  57. }
  58.  
  59. #endif /* XPKMASTER_XBUF_C */
  60.